//
//  TCLYIntegralTableViewCell.m
//  YuErmuYing
//
//  Created by LYang on 16/9/2.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "TCLYIntegralTableViewCell.h"
#import "TCLYIntegralCollectionViewCell.h"
#import "TCLYTwoIntegralCollectionViewCell.h"
#import "Macros.h"
#import "Masonry.h"

@implementation TCLYIntegralTableViewCell
-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]) {
//        self.backgroundColor = bgColor;
        UIView * bgView = [[UIView alloc] init];
        bgView.backgroundColor = [UIColor whiteColor];
        [self addSubview:bgView];
        [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(10);
            make.left.mas_equalTo(self);
            make.right.mas_equalTo(self);
            make.bottom.mas_equalTo(self);
        }];
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textColor = btnColor;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        [bgView addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(10);
            make.left.mas_equalTo(bgView.mas_left).offset(80);
            make.right.mas_equalTo(bgView.mas_right).offset(-80);
            make.height.mas_equalTo(20);
        }];
        
        self.moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.moreBtn setImage:[UIImage imageNamed:@"right"] forState:UIControlStateNormal];
        [bgView addSubview:self.moreBtn];
        [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(bgView.mas_right).offset(-12);
            make.top.mas_equalTo(self.titleLabel);
            make.width.mas_equalTo(15);
            make.height.mas_equalTo(20);
        }];
        
        UILabel * moreLabel = [[UILabel alloc] init];
        moreLabel.text = @"更多";
        moreLabel.textColor = blackFont;
        moreLabel.font = [UIFont systemFontOfSize:14];
        moreLabel.textAlignment = NSTextAlignmentCenter;
        [bgView addSubview:moreLabel];
        [moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.titleLabel);
            make.right.mas_equalTo(self.moreBtn.mas_left).offset(-6);
            make.width.mas_equalTo(30);
            make.height.mas_equalTo(20);
        }];
        
        UICollectionViewFlowLayout * layout1 = [[UICollectionViewFlowLayout alloc]init];
        layout1.itemSize = CGSizeMake((screenWidth-12)/2,120);
        layout1.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
        layout1.scrollDirection = UICollectionViewScrollDirectionVertical;
        self.oneCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 40, screenWidth, 120) collectionViewLayout:layout1];
        self.oneCollectionView.backgroundColor = [UIColor whiteColor];
        [self.oneCollectionView registerClass:[TCLYIntegralCollectionViewCell class] forCellWithReuseIdentifier:@"integralCell"];
        [self addSubview:self.oneCollectionView];
        
        UICollectionViewFlowLayout * layout2 = [[UICollectionViewFlowLayout alloc]init];
        layout2.itemSize = CGSizeMake(screenWidth/4, screenWidth/4+40);
        layout2.minimumLineSpacing = 0;
        layout2.minimumInteritemSpacing = 0;
        layout2.scrollDirection = UICollectionViewScrollDirectionVertical;
        self.twoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 160, screenWidth, screenWidth/4+40) collectionViewLayout:layout2];
        [self.twoCollectionView registerClass:[TCLYTwoIntegralCollectionViewCell class] forCellWithReuseIdentifier:@"twoIntegralCell"];
        self.twoCollectionView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.twoCollectionView];
    }
    return self;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
